import sys
import numpy as np
import ctypes

sys.path.append("../utils")

from utils import OpRunner, compare, verify_result
import time


def main():
    func = OpRunner("./build/libop.so", 2, pint_time=True)
    func.op.run.argtypes = None
    minvalue = 1
    maxvalue = 10
    shape = [1024 * 1024]
    # for dtype in [np.float16, np.float32]:
    for dtype in [np.float32]:
        # input_x = np.random.uniform(minvalue, maxvalue, shape).astype(dtype)
        # input_x = np.array([1, 0, -1, 1, 3], dtype)
        input_x = np.ones(shape, dtype=dtype)
        output = np.ones(shape, dtype=dtype)
        func([input_x, output], [-1])

        flag = input_x > 2
        golden = 1 / input_x[flag]
        print(golden)
        # print((output!=1).all())
        print(output)

        # if verify_result(output, golden):
        #     print(dtype,  "成功")
        # else:
        #     print(dtype,  "失败")


if __name__ == "__main__":
    main()
